﻿@model CloudStorageLight.Core.BlobItem
@{
    Layout = null;
    var tmz = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
    var filetype = Path.GetExtension(Model.Name);
    var visibleCheckbox = ViewData["VisibleItemCheckbox"] == null ? true : (bool)ViewData["VisibleItemCheckbox"];
}

@if (Model is CloudStorageLight.Core.BlobDirectory)
{
    <a href="@(CloudStorageLight.SampleWeb.Models.FileUrlUtil.EncodeFileUrl(Model.Name))/" class="list">
        <div class="list-content">
            <i class="@(Model.IsPublic() ? "icon-cloud" : "icon-folder-2") icon"></i>
            <div class="data">
                <span class="list-title item-name">@Model.Name</span>
                <span class="item-date" style="display:none;">@(Model.LastModified == null ? "" : Model.LastModified.Value.ToLocalTime().ToString("yyyyMMddHHmmss"))</span>
            </div>
            <span class="list-remark fg-darkRed"></span>
        </div>
    </a>
}
else
{
    <div class="list" >

        <div class="list-content">
            @{
                string icon = "icon-file";
                var file = (CloudStorageLight.Core.BlobFile)Model;
                switch (filetype)
                {
                    case ".doc":
                    case ".docx":
                        icon = "icon-file-word";
                        break;
                    case ".ppt":
                    case ".pptx":
                        icon = "icon-file-powerpoint";
                        break;
                    case ".xls":
                    case ".xlsx":
                        icon = "icon-file-excel";
                        break;
                    case ".pdf":
                        icon = "icon-file-pdf";
                        break;
                    case ".zip":
                        icon = "icon-file-zip";
                        break;
                    default:
                        break;
                }
            }

            <a href="@(Url.RouteUrl("files", new { id = "" }) + CloudStorageLight.SampleWeb.Models.FileUrlUtil.EncodeFileUrl(Model.Path))" target="preview"><i class="@icon icon"></i></a>
            <div class="data blobfile" data-href="@(Url.RouteUrl("files", new { id = ""}, Request.Url.Scheme) + CloudStorageLight.SampleWeb.Models.FileUrlUtil.EncodeFileUrl(Model.Path))">
                <span class="list-title">
                    <input type="checkbox" class="item-checkbox" name="@Model.Path"  @Html.Raw(visibleCheckbox ? "" : "style='display:none;'")/>
                    <span class="item-name">@Model.Title</span>
                </span>
                <div class="list-subtitle">
                    <span class="owner-userid">@Model.Owner</span>
                    <span>@(Model.LastModified == null ? "" : TimeZoneInfo.ConvertTime(file.UploadDate.Value, tmz).ToString("F"))</span>
                    <span class="item-date" style="display:none;">@(file.UploadDate == null ? "" : file.UploadDate.Value.ToLocalTime().ToString("yyyyMMddHHmmss"))</span>
                    <span>@(Model.Length <= 0 ? "" : CloudStorageLight.SampleWeb.Models.ExtensionMethods.ToReadableSIUnit(Model.Length))</span>
                    <span class="item-marker">
                        @if (file.IsCheckOut)
                        {
                            <i class="icon-pop-out fg-darkRed">@(string.Format(CloudStorageLight.SampleWeb.Models.Messages.MsgEditing, file.CheckOutUserId))</i>
                        }
                    </span>
                </div>
                <div class="list-description">
                    <a href="javascript:void(0);" class="item-description">@Html.Raw(Model.SearchContent)</a>
                </div>
                <span class="list-remark fg-darkRed">
                    @(ViewData["status"])
                </span>
            </div>
            <div class="list-context-menu"></div>
        </div>
    </div>
}
